package com.hzit.bj1804.dianweb.controller;

import com.github.pagehelper.PageInfo;
import com.hzit.bj1804.dian.entity.Diaryinfo;
import com.hzit.bj1804.dian.vo.LayuiTableData;
import com.hzit.bj1804.dianweb.service.DiaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class DiaryController {
    @Autowired
    DiaryService diaryService;
    /**
     * 根据分页查询所有登陆日志
     */
    @RequestMapping("seleAllPage")
    @ResponseBody
    public Object seleAllPage(@RequestParam(value = "limit",defaultValue = "5")int limit ,@RequestParam(value = "page",defaultValue = "1")int pag){
        LayuiTableData data = new LayuiTableData();
        List<Diaryinfo> list = diaryService.seleAll();
        PageInfo<Diaryinfo> pageInfo = diaryService.seleAllPage(limit, pag);
        List<Diaryinfo> diaryinfos = pageInfo.getList();
        data.setData(diaryinfos);
        data.setCode(0);
        data.setCount(list.size());
        data.setMsg("");
        return data;
    }
    @RequestMapping("insertdiary")
    @ResponseBody
    /**
     * 添加会员的接口
     */
    public Object insert( Diaryinfo diaryinfo){
        return diaryService.insert(diaryinfo);
    }








//    @RequestMapping("membermanage")
//    public Object one(){
//        return "netshop/membermanage";
//    }
//    @RequestMapping("in")
//    public Object onew(){
//        return "netshop/login";
//    }
//    @RequestMapping("member_report")
//    public Object two(){
//        return "netshop/member_report";
//    }
//    @RequestMapping("product_list")
//    public Object three(){
//        return "netshop/product_list";
//    }
//    @RequestMapping("itemadd")
//    public Object ten(){
//        return "netshop/itemadd";
//    }
//    @RequestMapping("edit_commodity")
//    public Object four(){
//        return "netshop/edit_commodity";
//    }
//    @RequestMapping("category_list")
//    public Object five(){
//        return "netshop/category_list";
//    }
//    @RequestMapping("order_list")
//    public Object six(){
//        return "netshop/order_list";
//    }
//    @RequestMapping("log")
//    public Object seven(){
//        return "netshop/log";
//    }
//    @RequestMapping("system_login")
//    public Object eight(){
//        return "netshop/system_login";
//    }
//    @RequestMapping("change_password")
//    public Object nine(){
//        return "netshop/change_password";
//    }
//    @RequestMapping("moban")
//    public Object moban(){
//        return "moban";
//    }

}
